home *** CD-ROM | disk | FTP | other *** search
- Path: uni-duisburg.de!news
- From: mauch@uni-duisburg.de (Michael Mauch)
- Newsgroups: comp.lang.c++,comp.os.msdos.programmer
- Subject: Re: 'interrupt' in Turbo C++
- Date: Tue, 16 Jan 1996 21:31:34 +0100
- Organization: Gesamthochschule Duisburg
- Message-ID: <30faf82f.750220@news.uni-duisburg.de>
- References: <4d4p12$67h@fang.dsto.defence.gov.au>
- NNTP-Posting-Host: slip12.uni-duisburg.de
- X-Newsreader: Forte Agent .99c/16.141
-
- Hi!
-
- dpr@itd.dsto.gov.au (David Rajaratnam) wrote:
-
- >
- > Hi there,
- > I hope I've got the right newsgroups for this question.
- > I'm having problems writing an interrupt handler using
- > Borland Turbo C++ v3 for DOS. The problem arises when
- > I want the interrupt function to return results via
- > the registers.
- >
- > Under C what I do is;
- >
- > typedef struct {
- > int bp, di, si, ds, es, dx, cx, bx, ax, ip, cs, fl;
- > } IREGS;
- >
- > static void interrupt (*mycinterrupt)(IREGS ir){
- >
- > <do stuff>
- >
- > ir.ax = _AX
- > }
- >
- [...]
- > Unfortunately, the declaration of setvect and getvect in C++
- > does things a bit differently. I quote;
- >
- > Syntax
- > void interrupt(*getvect(int interruptno))(); /*C version*/
- > void interrupt(*getvect(int interruptno))(...); //C++ version
- > void setvect(int interruptno, void interrupt (*isr)()); /*C version*/
- > void setvect(int interruptno, void interrupt (*isr)(...)); //C++ version
- >
- > So making the call setvect(0xXX, mycinterrupt) will give me a
- > compiler error now. To get around this what I tried to do was;
- >
- > static void interrupt (*mycppinterrupt)(...){
- > IREGS *ir;
- >
- > <do stuff>
- >
- > ir = (IREGS *)...;
- > ir->ax = _AX;
- > }
- >
- > Although this version compilied, when run the results where
- > not what I was hoping for. I also tried using the <stdarg.h>
- > stuff but they gave me the same results as above. I can only
- > guess that what C++ expects to see is different to the
- > C version. Unfortunately nowhere in the Documentation (that
- > I can find), or other books I own, does it describe what
- > C++ expects. Mind you the arguments of the C version were
- > not adequately described either, it's just that I happened
- > to come across an example that used the
- > tydef struct { bp, ...} IREGS method.
-
-
- typedef struct
- {
- int bp, di, si, ds, es, dx, cx, bx, ax, ip, cs, fl;
- } IREGS;
-
-
- #ifdef __cplusplus
- typedef void interrupt (*ISR_t)(...);
- #else
- typedef void interrupt (*ISR_t)(IREGS iregs);
- #endif
-
- void far interrupt NewIntHandler(IREGS iregs)
- {
- <do_stuff>
- }
-
- setvect(IntNum,(ISR_t)NewIntHandler);
- // will work in C and C++ now
-
- Hope this helps...
- Michael
-
-